//用户管理模块的接口


import request from "../../../utils/request";
//应用ts类型
import type { ApiResponse, UserRecord } from './userType'
import type { Response } from './rolesType'
import type { assignUserRole } from "./assignUser";

//枚举地址
enum API {
  ALLUSER_URL = '/admin/acl/user/',
  UPDATA_URL = '/admin/acl/user/update',
  ADD_URL = '/admin/acl/user/save',
  DELETE_URL = '/admin/acl/user/remove/',
  GETROLES_URL = '/admin/acl/user/toAssign/',
  SAVEROLES_URL = '/admin/acl/user/doAssignRole/',
  SELECTDELETE_URL = '/admin/acl/user/batchRemove'
}
//定义获取用户账号信息的接口
export const reqGetUserInfo = (page: number, limit: number,username:string) => request.get<any, ApiResponse>(API.ALLUSER_URL + `${page}/${limit}/?username=${username}`)
//保存接口
export const reqAddOrUpdata = (data: UserRecord) => {
  if (data.id) {
    request.put<any, any>(API.UPDATA_URL, data)
  } else {
    request.post<any, any>(API.ADD_URL, data)
  }
}
//删除接口
export const reqDelete = (id: number | string) => request.delete<any, any>(API.DELETE_URL + id)
//获取职位接口
export const reqGetRoles = (userId: number | string) => request.get<any, Response>(API.GETROLES_URL + userId)
//保存职位接口
export const reqSaveRoles = (data: assignUserRole) => request.post<any, any>(API.SAVEROLES_URL, data);
//批量删除接口
export const reqSelectDelete = (idList: number[]) => request.delete<any, any>(API.SELECTDELETE_URL, {data:idList})


